home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / UIFlow 1.0.1 / UIFlow Source / VSet2.0 / Src / vg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-06  |  9.7 KB  |  318 lines  |  [TEXT/????]

  1. /*****************************************************************************
  2. *              NCSA HDF Vset release 2.1
  3. *                    May 1991
  4. *
  5. * NCSA HDF Vset release 2.1 source code and documentation are in the public
  6. * domain.  Specifically, we give to the public domain all rights for future
  7. * licensing of the source code, all resale rights, and all publishing rights.
  8. * We ask, but do not require, that the following message be included in all
  9. * derived works:
  10. * Portions developed at the National Center for Supercomputing Applications at
  11. * the University of Illinois at Urbana-Champaign.
  12. * THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
  13. * SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
  14. * WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
  15. *****************************************************************************
  16. *  Likkai Ng MAY 91  NCSA
  17. * vg.h
  18. * Part of HDF VSet interface
  19. *
  20. * defines symbols and structures used in all v*.c files    
  21. *
  22. * NOTES:
  23. * This include file depends on the basic HDF *.h files dfi.h and df.h.
  24. * An 'S' in the comment means that that data field is saved in the HDF file.
  25. *
  26. ******************************************************************************/
  27.  
  28.  
  29. #include <df.h>
  30.  
  31. #define PUBLIC        
  32. #define PRIVATE    static
  33.  
  34.  
  35.  
  36. /* 
  37. * interlacing supported by the vset. 
  38. */
  39.  
  40. #define FULL_INTERLACE    0
  41. #define NO_INTERLACE        1
  42.  
  43. /* 
  44. * some max lengths 
  45. *
  46. * Except for FIELDNAMELENMAX, change these as you please, they 
  47. * affect memory only, not the file. 
  48. *
  49. */
  50.  
  51. #define FIELDNAMELENMAX    16                /* fieldname   : 16 chars max */
  52.  
  53. #define VSFIELDMAX        20              /* max no of fields per vdata */
  54. #define VSNAMELENMAX        64                /* vdata name  : 64 chars max */    
  55. #define VGNAMELENMAX        64                /* vgroup name : 64 chars max */    
  56. #define VFILEMAX             40             /* max no of files that may be opened */
  57. /* actually, for now, this is the max # of file units that can be used */
  58.  
  59.  
  60. /*
  61. * definition of the 2 data elements of the vset.
  62. */
  63.  
  64. typedef struct vgroup_desc         VGROUP;
  65. typedef struct vdata_desc            VDATA;
  66.  
  67. typedef VDATA VSUBGROUP;
  68.  
  69.  
  70. /*
  71. * -----------------------------------------------------------------
  72. * structures that are part of the VDATA structure
  73. * -----------------------------------------------------------------
  74. */
  75.  
  76. typedef struct symdef_struct 
  77. {
  78.     char* name;                        /* symbol name */
  79.     int    type;                        /* whether int, char, float etc */
  80.     int    isize;                    /* field size as stored in vdata */
  81.     int    order;                    /* order of field */
  82.  
  83.     } SYMDEF;
  84.  
  85. typedef struct write_struct    
  86. {
  87.     int32    n;                            /* S actual # fields in element */
  88.     int    ivsize;                    /* S size of element as stored in vdata */
  89.      char     name[VSFIELDMAX][FIELDNAMELENMAX+1];
  90.                                         /* S name of each field */
  91.     int    len[VSFIELDMAX];         /* S length of each fieldname */
  92.     int    type[VSFIELDMAX];        /* S field type */
  93.       int    off[VSFIELDMAX];        /* S field offset in element in vdata */
  94.       int     isize[VSFIELDMAX];    /* S internal (HDF) size [incl order] */
  95.       int    order[VSFIELDMAX];    /* S order of field */
  96.       int    esize[VSFIELDMAX];    /*  external (local machine) size [incl order] */
  97.     int    (*toIEEEfn  [VSFIELDMAX] )();
  98.     int    (*fromIEEEfn[VSFIELDMAX] )();
  99.  
  100.       }         VWRITELIST;
  101.  
  102. typedef struct read_struct
  103. {
  104.     int    n;                         /* # fields to read */
  105.     int    item[VSFIELDMAX];     /* index into vftable_struct */
  106.  
  107.     } VREADLIST;
  108.  
  109. /* 
  110. *  ----------------------------------------------- 
  111.         V G R O U P     definition     
  112. *  ----------------------------------------------- 
  113. */
  114.  
  115. #define MAXNVELT  36                /* max no of elements in a vgroup */
  116.  
  117. struct vgroup_desc
  118.     int    otag, oref;            /* tag-ref of this vgroup */
  119.       DF         *f;                          /* HDF file ptr */
  120.     int16     nvelt;                     /* S no of elements */
  121.       int     access;                    /* 'r' or 'w' */
  122.     int     tag[MAXNVELT];        /* S tag of element */
  123.     int     ref[MAXNVELT];        /* S ref of element */
  124.      char     vgname[VGNAMELENMAX+1];/* S name of this vgroup */
  125.      char     vgclass[VGNAMELENMAX+1];/*  class name of this vgroup */
  126.     VDATA* velt[MAXNVELT];         /* pts to a element if opened; or else NULL */
  127.     int    marked;                    /* =1 if new info has been added to vgroup */
  128.     int16        extag, exref;            /* expansion tag-ref */
  129.     int16        version, more;            /* version and "more" field */    
  130.  
  131.     };                                    /* VGROUP */
  132.  
  133. /*
  134. *  ----------------------------------------------- 
  135. *         V D A T A      definition   
  136. *  ----------------------------------------------- 
  137. */
  138.  
  139. #define USYMMAX 36                /* max user-defined symbols allowed */
  140.  
  141. struct vdata_desc{ 
  142.       int    otag, oref;             /* tag,ref of this vdata */
  143.       DF        *f;                          /* HDF file ptr */
  144.       int    access;                    /* 'r' or 'w' */
  145.      char    vsname[VSNAMELENMAX+1];/* S name of this vdata */
  146.      char    vsclass[VSNAMELENMAX+1];/* class name of this vdata */
  147.       int    interlace;                /* S  interlace as in file */
  148.       int32    nvertices;                /* S  #vertices in this vdata */
  149.     int    vpos;                    /* cur position (in terms of elements) */
  150.     VWRITELIST    wlist;
  151.       VREADLIST    rlist;
  152.     int              nusym;
  153.     SYMDEF         usym[USYMMAX];
  154.     int    marked;                    /* =1 if new info has been added to vdata */
  155.  
  156.     int16        extag, exref;            /* expansion tag-ref */
  157.     int16        version, more;            /* version and "more" field */    
  158.  
  159.       };                                  /* VDATA */ 
  160.  
  161. /* MACROS - Use these for accessing field components of vdata. */
  162.  
  163. #define VFnfields(vdata)         (vdata->wlist.n)
  164. #define VFfieldname(vdata,t)     (vdata->wlist.name[t])
  165. #define VFfieldtype(vdata,t)     (vdata->wlist.type[t])
  166. #define VFfieldisize(vdata,t)     (vdata->wlist.isize[t])
  167. #define VFfieldesize(vdata,t)     (vdata->wlist.esize[t])
  168. #define VFfieldorder(vdata,t)     (vdata->wlist.order[t])
  169.  
  170.  
  171. /* --------------  H D F    V S E T   tags  ---------------------------- */
  172.  
  173. #define OLD_VGDESCTAG      61820        /* tag for a vgroup d*/ 
  174. #define OLD_VSDESCTAG     61821        /* tag for a vdata descriptor */
  175. #define OLD_VSDATATAG     61822        /* tag for actual raw data of a vdata */ 
  176.  
  177. #define NEW_VGDESCTAG    1965
  178. #define NEW_VSDESCTAG    1962
  179. #define NEW_VSDATATAG    1963
  180.  
  181. #define VGDESCTAG         NEW_VGDESCTAG 
  182. #define VSDESCTAG         NEW_VSDESCTAG 
  183. #define VSDATATAG          NEW_VSDATATAG 
  184.  
  185. /*
  186. * Actual sizes of data types stored in HDF file, and are IEEE-defined. 
  187. */
  188.  
  189. #define IEEE_UNTYPEDSIZE   0
  190. #define IEEE_CHARSIZE      1
  191. #define IEEE_INT16SIZE     2
  192. #define IEEE_INT32SIZE     4
  193. #define IEEE_FLOATSIZE     4
  194.  
  195. /*
  196. * types used in defining a new field via a call to VSfdefine
  197. */
  198.  
  199. #define LOCAL_NOTYPE            0
  200. #define LOCAL_CHARTYPE      1
  201. #define LOCAL_INTTYPE          2
  202. #define LOCAL_FLOATTYPE        3
  203. #define LOCAL_LONGTYPE          4
  204.  
  205. /*
  206. * actual LOCAL MACHINE sizes of the above types
  207. */
  208.  
  209. #define LOCAL_UNTYPEDSIZE  0
  210. #define LOCAL_CHARSIZE      sizeof(unsigned char)
  211. #define LOCAL_INTSIZE          sizeof(int)
  212. #define LOCAL_LONGSIZE         sizeof(long)
  213. #define LOCAL_FLOATSIZE     sizeof(float)
  214.  
  215. /* ------------------------------------------------------------------ */
  216. /* 2 GLOBAL VARIABLES (int vjv and char sj[]) provide a simple
  217. * debugging scheme. Debugging is turned on and off via calls to 
  218. * setjj and setnojj. These globals and functions are found in vgp.c.
  219. * If the debug feature is no longer needed, delete all these, and
  220. * all statements that refer to xzj,sjs, and vjv from the source
  221. *
  222. */
  223.  
  224. extern int         vjv;             /* debugger switch */
  225. extern char     sjs[];         /* contains the debug/error message */
  226.  
  227. /* zj just prints out the contents of the text buffer sjs. */
  228. /* sjs contains debugging messages when debug is on */
  229. /* for the Mac, replace define zj to be any print msg routine */
  230. /* for printf and fprintf - there should be some Mac equivalent */
  231.  
  232. #ifdef MAC
  233. #define printf
  234. #define fprintf
  235. #define zj
  236. #else
  237. #define zj         fprintf(stderr,"%s",sjs) 
  238. #endif
  239.  
  240. /* Macros for returning null, -1 or no value with a message */
  241.  
  242. #define FAIL -1
  243. #define RTNULL(ss) { sprintf(sjs,"@%s\n",ss); zj; return(NULL); }
  244. #define RTNEG(ss) { sprintf(sjs,"@%s\n",ss); zj; return(FAIL); }
  245. #define RT(ss) { sprintf(sjs,"@%s\n",ss); zj; return; }
  246.  
  247. /* .................................................................. */
  248. /* Private data structures. Unlikely to be of interest to applications */
  249. /* 
  250. * These are just typedefs. Actual vfile_ts are declared PRIVATE and
  251. * are not accessible by applications. However, you may change VFILEMAX
  252. * to allow however many files to be opened.
  253. *
  254. * These are memory-resident copies of the tag-refs of the vgroups
  255. * and vdatas for each file that is opened.
  256. */
  257.  
  258. /* this is a memory copy of a vs tag/ref found in the file */
  259. typedef struct vg_instance_struct {
  260.     int     ref;            /* ref # of this vgroup in the file */
  261.     int     nattach;        /* # of current attachs to this vgroup */
  262.     int     nentries;    /* # of entries in that vgroup initially */
  263.     VGROUP *vg;            /* points to the vg when it is attached */
  264. struct vg_instance_struct * next;
  265. }    vginstance_t; 
  266.  
  267. /* this is a memory copy of a vs tag/ref found in the file */
  268. typedef struct vs_instance_struct {
  269.     int    ref;            /* ref # of this vdata in the file */
  270.     int    nattach;        /* # of current attachs to this vdata */
  271.     int    nvertices;    /* # of elements in that vdata initially */
  272.     VDATA    * vs;         /* points to the vdata when it is attached */
  273.     struct vs_instance_struct * next;
  274. }    vsinstance_t; 
  275.  
  276. /* each vfile_t maintains 2 linked lists: one of vgs and one of vdatas
  277. * that already exist or are just created for a given file.  */
  278.  
  279. typedef struct vfiledir_struct {
  280.     DF            * f;
  281.  
  282.    int                vgtabn;                /* # of vg entries in vgtab so far */
  283.     vginstance_t    vgtab;                /* start of vg linked list */
  284.    vginstance_t    *vgtabtail;             /* its tail end */
  285.  
  286.    int                vstabn;                /* # of vs entries in vstab so far */
  287.     vsinstance_t    vstab;                /* start of vs linked list */
  288.    vsinstance_t    *vstabtail;            /* its tail end */
  289. } vfile_t;
  290.  
  291. /* .................................................................. */
  292. #define VSET_VERSION 2                    /* DO NOT CHANGE!! */
  293.  
  294. #ifdef MAC
  295. #include "vset-prototypes.h"
  296. #include <String.h>
  297. #include <ctype.h>
  298. #endif
  299.  
  300. /* 
  301. * DFopen and DFclose are redefined to perform additional work, 
  302. * ie Vset data structure initialization and clean-up.
  303. * Does not affect usage by other HDF interfaces.
  304. */
  305.  
  306. #define DFopen  DFvsetopen
  307. #define DFclose DFvsetclose
  308.  
  309.